package com.ledict.casefiling.action;

import org.springframework.web.HttpRequestHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping(name = "/")
public class LoginController {

    @RequestMapping("/login")
    public String login(HttpServletRequest request, Map<String, Object> map) {
        // 登录失败从request中获取shiro处理的异常信息,全类名为shiroLoginFailure
        String exception = (String) request.getAttribute("shiroLoginFailure");

        String errMsg = "";
        if (null != exception) {
           /* if (UnknownAccountException.class.getName().equals(exception)) {
                errMsg = "UnknownAccountException -- > 账号不存在：";
            } else if (IncorrectCredentialsException.class.getName().equals(exception)) {
                errMsg = "IncorrectCredentialsException -- > 密码不正确：";
            } else if ("kaptchaValidateFailed".equals(exception)) {
                errMsg = "kaptchaValidateFailed -- > 验证码错误";
            } else {
                errMsg = "" + exception;
            }*/
        }

        map.put("errMsg", errMsg);

        return "/login";
    }
}
